package util;

import java.util.Date;

import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableModel;


public class EventTableModel extends AbstractTableModel {

	private String[] columnNames = null;
	private Object[][] data = null;
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public EventTableModel(String[] titles) {
		super();
		columnNames = titles;	
	}
	
	public EventTableModel(Object[][] events, String[] titles) {
		super();
		columnNames = titles;
		data = events;
	}

	@Override
	public int getColumnCount() {
		return columnNames.length;
	}

	@Override
	public int getRowCount() {
		return data.length;
	}
	
	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		return data[rowIndex][columnIndex];
	}

	public void setEvents(Object[][] events) {
		data = events;
	}
	
    @Override
    public Class<?> getColumnClass( int column ) {
        switch( column ){
            case 0: return Integer.class;
            case 1: return Date.class;
            case 2: return String.class;
            case 3: return String.class;
            default: return Object.class;
        }
    }
    
    public String getColumnName(int columnIndex) {
        return columnNames[columnIndex];
    }
}
